import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/utils/input_formatter_tools.dart';
import 'package:finance_app/src/widgets/form/form_edit_status_inherited_widget.dart';
import 'package:flutter/material.dart';

class CpfDonorInputField extends StatelessWidget {
  final TextEditingController controller;
  final bool hasBottomBorder;
  const CpfDonorInputField({
    Key key,
    @required this.controller,
    this.hasBottomBorder = true,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    bool isEdit = FormEditStatusInheritedWidget.ofEnable(context);

    return Container(
      padding: EdgeInsets.only(left: 40, right: 20),
      decoration: BoxDecoration(
        border: hasBottomBorder
            ? Border(
                bottom: BorderSide(
                  color: aceGrayColor,
                  width: getDp(0.5),
                ),
              )
            : null,
      ),
      child: Row(
        children: [
          Text(
            '${S.current.donor}: ',
            style: TextStyle(fontSize: 15),
          ),
          Expanded(
            child: Container(
              transform: Matrix4.translationValues(0, 2.5, 0),
              child: TextFormField(
                controller: controller,
                inputFormatters: [intInputFormatter],
                keyboardType: TextInputType.number,
                scrollPadding: EdgeInsets.zero,
                enabled: isEdit,
                style: TextStyle(
                    fontSize: getSp(16),
                    color: isEdit ? aceBlueColor : aceBlackColor,
                    fontWeight: FontWeight.w700,
                    height: 14 / 16),
                decoration: InputDecoration(
                    isCollapsed: false,
                    border: InputBorder.none,
                    focusedBorder: InputBorder.none,
                    disabledBorder: InputBorder.none,
                    hintText: '0',
                    hintStyle: TextStyle(
                        fontWeight: FontWeight.bold,
                        color: isEdit ? aceBlueColor : aceBlackColor,
                        fontSize: getSp(16),
                        height: 16 / 16),
                    labelStyle: TextStyle(
                        fontWeight: FontWeight.w400,
                        fontSize: getSp(16),
                        height: 16 / 16)),
              ),
            ),
          ),
        ],
      ),
    );
    ;
  }
}
